package com.jman.user.controller;


import com.jman.user.domain.User;
import com.jman.user.dto.UserDTO;
import com.jman.user.dto.UserWithToken;
import com.jman.user.service.impl.UserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserServiceImpl userService;

    @GetMapping("/{phone}")
    public UserWithToken getUser(@PathVariable String phone){
        return userService.getUserByPhone(phone);
    }

    @PostMapping("/save")
    public UserWithToken saveUser(@RequestBody User user){
        String phone = user.getPhone();
        String password = user.getPassword();
        return userService.saveUser(phone, password);
    }
}
